package day_02_02_JMM;

import java.util.concurrent.TimeUnit;

/**
 * @Description
 * @Author shihan
 * @Date 2020/11/21 17:40
 * @Version 1.0
 */
public class JMMStudy_02 {

    public static volatile boolean flag = false;

    public static void main(String[] args) {
        new Thread(() -> {
            System.out.println("waiting data...");
            while (!flag){

            }
            System.out.println("==========success!");
        },"A").start();

        try { TimeUnit.SECONDS.sleep(2); } catch (InterruptedException e) { e.printStackTrace(); }
        
        new Thread(() -> {
            System.out.println("change flag to true start ...");
            flag = true;
            System.out.println("change flag to true end ...");
        },"").start();
    }

}
